"""Definition of the contact content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

from Products.plonecrm import plonecrmMessageFactory as _
from Products.plonecrm.interfaces import Icontact
from Products.plonecrm.config import PROJECTNAME

contactSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.ImageField(
        'portrait',
        storage=atapi.AnnotationStorage(),
        widget=atapi.ImageWidget(
            label=_(u"personal photo"),
            description=_(u"personal photo"),
        ),
        validators=('isNonEmptyFile'),
    ),


    atapi.StringField(
        'comments',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"comments"),
            description=_(u"Field description"),
        ),
    ),


    atapi.StringField(
        'duty',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"work duty"),
            description=_(u"work duty"),
        ),
    ),


    atapi.StringField(
        'resume',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"person resume"),
            description=_(u"person resume"),
        ),
    ),


    atapi.StringField(
        'background',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"home background"),
            description=_(u"home background"),
        ),
    ),


    atapi.StringField(
        'habit',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"habits"),
            description=_(u"habits"),
        ),
    ),


    atapi.StringField(
        'email',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"email"),
            description=_(u"email address"),
        ),
        validators=('isEmail'),
    ),


    atapi.StringField(
        'position',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"position"),
            description=_(u"work position"),
        ),
    ),


    atapi.StringField(
        'addr',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"address"),
            description=_(u"address"),
        ),
    ),


    atapi.StringField(
        'mobile',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"mobile phone"),
            description=_(u"mobile phone number"),
        ),
    ),


    atapi.StringField(
        'homephone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"home phone"),
            description=_(u"home phone number"),
        ),
    ),


    atapi.StringField(
        'officephone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"New Field"),
            description=_(u"office phone number"),
        ),
    ),


    atapi.StringField(
        'department',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"New Field"),
            description=_(u"Field description"),
        ),
    ),


    atapi.StringField(
        'gender',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"gender"),
            description=_(u"gender"),
        ),
    ),


    atapi.StringField(
        'name',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"contact name"),
            description=_(u"contact name"),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

contactSchema['title'].storage = atapi.AnnotationStorage()
contactSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(contactSchema, moveDiscussion=False)


class contact(base.ATCTContent):
    """contact person"""
    implements(Icontact)

    meta_type = "contact"
    schema = contactSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    portrait = atapi.ATFieldProperty('portrait')

    comments = atapi.ATFieldProperty('comments')

    duty = atapi.ATFieldProperty('duty')

    resume = atapi.ATFieldProperty('resume')

    background = atapi.ATFieldProperty('background')

    habit = atapi.ATFieldProperty('habit')

    email = atapi.ATFieldProperty('email')

    position = atapi.ATFieldProperty('position')

    addr = atapi.ATFieldProperty('addr')

    mobile = atapi.ATFieldProperty('mobile')

    homephone = atapi.ATFieldProperty('homephone')

    officephone = atapi.ATFieldProperty('officephone')

    department = atapi.ATFieldProperty('department')

    gender = atapi.ATFieldProperty('gender')

    name = atapi.ATFieldProperty('name')


atapi.registerType(contact, PROJECTNAME)
